#include <iostream>
#include <string>
#include <stack>

using namespace std;

int main()
{
	char c;
	int status = 0;
	string cur;
	int l = 0, r = 0;
	while (cin >> c)
	{
		switch (status)
		{
		case 0:
			status = 1;
			break;
		case 1:
			if (c == ')') {
				if (l < r) {
					l++;
					cur += c;
				}
				else {
					status = 0;
					cout << cur;
					cur.clear();
				}
			}
			else {
				cur += c;
				r++;
			}
		}
	}
	return 0;
}